<?php

//get all case	
function getAllCase(){
	$qr ="SELECT * FROM `case`";
	return mysql_query($qr);
}

//add case	
function addCase($title,$description,$caseMonth,$caseYear,$customerID,$priorityID){
	$qr ="INSERT INTO `case`(Title,Description,CaseMonth,CaseYear,CustomerID,PriorityID) VALUES('$title','$description','$caseMonth','$caseYear','$customerID','$priorityID')";
	mysql_query($qr);
}

//get case by id	
function getCaseByID($caseID){
	$qr ="SELECT * FROM `case` WHERE CaseID = $caseID;";
	return mysql_query($qr);
}

//edit case	
function editCase($title,$description,$statusID,$solution,$caseID){
	$qr ="UPDATE `case` 
	SET Title = '$title',
	Description = '$description', 
	StatusID = '$statusID', 
	Solution = '$solution'
	WHERE CaseID = $caseID; ";
	mysql_query($qr);
}

//delete case	
function deleteCase($caseID){
	$qr ="DELETE FROM `case` WHERE CaseID = $caseID; ";
	mysql_query($qr);
}

//get total number of case	
function getTotalNumberOfCase(){
	$listCase = getAllCase();
	if($listCase == NULL) return 0;
	return mysql_num_rows($listCase);
}

//get number of case in specific status
function getNumberOfCaseByStatus($status){
	$qr ="SELECT * FROM `case` WHERE StatusID = $status";
	$listCaseByStatus = mysql_query($qr);
	if($listCaseByStatus == NULL) return 0;
	return mysql_num_rows($listCaseByStatus);
}


?>